/*
 * @Description:
 * @Author: qingyang
 * @Date: 2022-06-07 11:30:58
 * @LastEditors: qingyang
 * @LastEditTime: 2023-04-03 16:21:46
 */
const validateModel = (rule: any, value: string, callback: Fn) => {
  if (value == '') {
    callback(new Error('产品名称不能为空'));
  } else if (value && value.length > 255) {
    callback(new Error('产品名称长度最大为255'));
  } else {
    callback();
  }
};
export const rules = {
  modelName: [
    {
      required: true,
      validator: validateModel,
      trigger: ['submit', 'change']
    }
  ],
  modelCode: [
    {
      required: true,
      message: '产品编码不能为空',
      trigger: ['submit', 'change']
    }
  ],
  specification: [
    {
      required: true,
      message: '规格型号不能为空',
      trigger: ['submit', 'change']
    }
  ],
  num: [
    {
      required: true,
      message: '核算数量不能为空',
      trigger: ['submit', 'change']
    },
    {
      pattern: /[^((^\-?0+$)|(^\-?0+.0+$)|(^\-?.0+$))]/g,
      message: '核算数量不可为0',
      trigger: ['submit', 'change', 'blur']
    }
    // numberValidator(3, false, false)
  ],
  unit: [
    {
      required: true,
      message: '核算单位不能为空',
      trigger: ['submit', 'change']
    }
  ],
  accountYear: [
    {
      required: true,
      message: '核算年份不能为空',
      trigger: ['submit', 'change']
    }
  ],
  weight: [
    {
      required: true,
      message: '产品重量不能为空',
      trigger: ['submit', 'change']
    },
    {
      pattern: /[^((^\-?0+$)|(^\-?0+.0+$)|(^\-?.0+$))]/g,
      message: '产品重量不可为0',
      trigger: ['submit', 'change', 'blur']
    }
  ],
  manufactureCountry: [
    {
      required: true,
      message: '产地国家不能为空',
      trigger: ['submit', 'change']
    }
  ],
  manufactureAddress: [
    {
      required: true,
      message: '详细地址不能为空',
      trigger: ['submit', 'change']
    }
  ],
  accountBoundary: [
    {
      required: true,
      message: '核算范围不能为空',
      trigger: ['submit', 'change']
    }
  ],
  standard: [
    {
      required: true,
      message: '核算标准不能为空',
      trigger: ['submit', 'change']
    }
  ],
  accountStage: [
    {
      required: true,
      message: '生命周期不能为空',
      trigger: ['submit', 'change']
    }
  ],
  modelType: [
    {
      required: true,
      message: '模型类型不能为空',
      trigger: ['submit', 'change']
    }
  ],
  vehicleType: [
    {
      required: true,
      message: '车辆类型不能为空',
      trigger: ['submit', 'change']
    }
  ],
  functionalUnit: [
    {
      required: true,
      message: '功能单位不能为空',
      trigger: ['submit', 'change']
    }
  ],
  referenceFlowValue: [
    {
      required: true,
      message: '参考流不能为空',
      trigger: ['submit', 'change']
    }
  ]
};
